/**
 * 
 */
$(document).ready(function(){
     $("#errorMessage").addClass("forErrorMessage");
     $("#errorPasswordMessage").addClass("forErrorMessage");
});


$(function(){
	$("#loginButton").bind("click", function(){
		var loginId = $("#loginId").val();
		if(loginId == "" || loginId.length == 0){
			$("#errorMessage").empty();
			$("#errorMessage").append("Enter your ID");
			return;
		}
		
		var urlStr = "loginCheck.jsp?loginId=" + $("#loginId").val();
		$.ajax({
			url: urlStr,
			success: whenLoginSuccess,
			error: whenLoginError
		});
	});
});


function whenLoginSuccess(xml){
	var result = $(xml).find("RESULT").text();
	if(result == "OK"){
		document.location = "menu.jsp?loginId=" + $("#loginId").val();
	} else {
		$("#errorMessage").empty();
		$("#errorMessage").append("ID is not valid");
	}
}

function whenLoginError(result){
	$("#errorMessage").empty();
	$("#errorMessage").append("Server is not available : " + result);
}

